﻿using YK.Core.Enums;
using YK.Core.Extensions;

namespace YK.Core.Exceptions;


/// <summary>
/// 系统异常
/// </summary>
public class AppException : Exception
{
    public string AppMessage { get; set; }
    public int? AppCode { get; set; }
    public int StatusCode { get; set; } = HttpStatusCode.Status200Ok.Value();

    public AppException()
    {
    }

#if NET7_0
    public AppException(SerializationInfo serializationInfo, StreamingContext context)
        : base(serializationInfo, context)
    {
    }
#endif

    public AppException(string message)
        : base(message)
    {
        AppMessage = message;
    }

    public AppException(string message, int? code)
    : base(message)
    {
        AppMessage = message;
        AppCode = code;
    }

    public AppException(string message, int? code, int statusCode)
     : base(message)
    {
        AppMessage = message;
        AppCode = code;
        StatusCode = statusCode;
    }


    public AppException(string message, Exception innerException)
        : base(message, innerException)
    {
        AppMessage = message;
    }

    public AppException(string message, int? code, Exception innerException)
        : base(message, innerException)
    {
        AppMessage = message;
        AppCode = code;
    }

    public AppException(string message, int? code, int statusCode, Exception innerException)
        : base(message, innerException)
    {
        AppMessage = message;
        AppCode = code;
        StatusCode = statusCode;
    }
}
